package com.jiankangjin.appspos.services.impl;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import com.jiankangjin.appspos.services.ValidateServices;
import com.jiankangjin.appspos.util.ResourceMap;
import com.jiankangjin.appspos.vo.UpdateValidateImgVo;
import com.jiankangjin.httpclient.HttpClient;

@Service
public class ValidateServicesImpl  implements ValidateServices{
	private static final transient Log logger = LogFactory.getLog(ValidateServicesImpl.class);
	
	/**
	 * 更新验证码
	 */
	@Override
	public UpdateValidateImgVo updateValidateImg() {
		UpdateValidateImgVo updateValidateImgVo = new UpdateValidateImgVo();
		try {
			HashMap<String, Object> params = new HashMap<String, Object>();
			params.put("tmpSsn", null);
			params.put("imgWidth", "100");
			params.put("imgHeight", "50");
			if (logger.isInfoEnabled()) {
				logger.info("调帐户系统更新验证码:"+params);
			}
			Map<String, Object> map = HttpClient.getInstance().doPOSTgetHashMap("/accmanage/update_validate_img", params);
			if (logger.isInfoEnabled()) {
				logger.info("帐户系统更新验证码返回:"+map);
			}
			if(map == null) {
				updateValidateImgVo.setResp_status("9999");
				updateValidateImgVo.setMsg("帐户系统更新验证码返回空");
				return updateValidateImgVo;
			}
			String[] resTip = ResourceMap.getArray("A_update_validate_img_" + (String) map.get("status"));
			updateValidateImgVo.setResp_status(resTip[0]);
			updateValidateImgVo.setMsg(resTip[1]);
			updateValidateImgVo.setTmp_ssn((String) map.get("tmpSsn"));
			updateValidateImgVo.setImg_url((String) map.get("imgUrl"));
			return updateValidateImgVo;
		} catch (Exception e) {
			logger.error(this, e);
			return updateValidateImgVo;
		}
	}

	

}
